package com.thoughtworks.preuniversity.biblioteca;

import java.util.HashMap;
import java.util.List;

/**
 * Created by padmavb on 6/17/14.
 */
//Job:Menu related operations
public class Menu {

    private HashMap<Integer,Object> menuItems=new HashMap<Integer, Object>();
    String listOfAvailableMenuOptions="Enter\n";

    public Menu(List<Object> menuItems){

        for(int index=0;index<menuItems.size();index++)
           this.menuItems.put(index+1,menuItems.get(index));
        listOfAvailableMenuItems();
    }
    public void listOfAvailableMenuItems(){

        for(int keySet :menuItems.keySet()){

            Object ob=menuItems.get(keySet);
            listOfAvailableMenuOptions+=keySet+" For "+((MenuOperation)ob).giveJobOfClass()+"\n";
        }
    }

    public void displayAvailableMenuItems() {

        UserInterface userInterface=new UserInterface();

        userInterface.displayMenuItems(listOfAvailableMenuOptions);
    }


    public boolean validateInputOption(int userChoice) {

        if (menuItems.containsKey(userChoice))
            return true;
        return false;
    }

    public Object getCorrespondingObject(int userChoice){


        Object ob=menuItems.get(userChoice);
        return ob;
    }
}
